# -*- coding: utf-8 -*-
"""
Module Description: 枚举工具集
Date: 2017/3/9
Author:Bai Jin Ping
"""


def enum_to_dict(enum):
    """
    将上面的enum转换为dict字典
    :param enum:枚举实例
    :return:dict
    """
    enum_k = [k for k in dir(enum) if k[:2] != '__']
    return {k: getattr(enum, k) for k in enum_k}


def enum_to_dict_change_index(enum):
    """
    将上面的enum转换为dict字典,并将原value作为索引
    :param enum:枚举实例
    :return:dict
    """
    enum_k = [k for k in dir(enum) if k[:2] != '__']
    return {getattr(enum, k): k for k in enum_k}